Examples of Document Links and Anchors

The Directory Structure

The following is the directory structure used in these examples, showing the placement of the files to which we will refer.
    ROOT (of the HTML server)
       rinn              (My directory under the server root.)
              file1.html
         linkex1 
              file4.html
         tutorial (home of this set of files, i.e. where we are now) 
              file2.html
            linkex2 
              file3.html

Linking from where I am on this server.

Note: As you choose one of the files using a partial URL, notice that your browser will form the complete URL, making a general request for the file. Each time that you request a file, you make a new connection to the server, and disconnect when you have received it.

Link to File1.htm using <A HREF="../file1.html">.
Link to File4.htm using <A HREF="../linkex1/file4.html">.
Link to File2.html using <A HREF="file2.html">.
Link to File3.htm using <A HREF="linkex2/file3.html">.

Linking from the root on this server.

Note: All of the URL's in this section begin with a "/". The "/" indicates that the path begins at the root. Note above that none of the URL's began with a "/". That indicates that the path began in the directory that we were in. The ".." specifies the parent directory.

Link to File1.htm using <A HREF="/rinn/file1.html"&ft;.
Link to File4.htm using <A HREF="/rinn/linkex1/html">.
Link to File2.htm using <A HREF="/rinn/tutorial/file2.html">.
Link to File3.htm using <A HREF="/rinn/tutorial/linkex2/file3.html">.

Linking using the complete URL

Note: We will be linking to the files on this server by specifying the entire URL. We could just as easily be specifying a file on another server.

Link to File1.html using
<A HREF="http://orchard.washtenaw.cc.mi.us:8080/file1.html">.

Link to File4.html using
<A HREF="http://orchard.washtenaw.cc.mi.us:8080/rinn/linkex1/file4.html">.

Link to File2.html using
<A HREF="http://orchard.washtenaw.cc.mi.us:8080/rinn/tutorial/file2.html">.

Link to File3.html using
<A HREF="http://orchard.washtenaw.cc.mi.us:8080/rinn/tutorial/linkex2/file3.html">.

Notice the similarity between specifying from the root of the server, and specifying the complete URL.

Linking to a document on another server

As noted above, to link to a document on a different server, just specify the complete URL for that document in the anchor. The following are some interesting WEB sites and documents.

The first site is the White House, and if we do not specify a document, we get the welcome document.

The Whitehouse using <A HREF="http://www.whitehouse.gov/">.

This one is also at the White House, but this time we will specify a document. This document is a brief history of Abraham Lincoln.

Abraham Lincoln biography using
<A HREF="http://www.whitehouse.gov/glimpse/presidents/html/al16.html">

From this document, if you choose to view President Lincoln's Second Inaugural Address, you will connect to:

hppt://www.cc.columbia.edu/acis/bartleby/inaugural/pres32.html

The Oakland Software Repository using
<A HREF="http://www.acs.oakland.edu/oak/oak.html">.


Try it Yourself.
Return to the Link Page.
Author: John J. Rinn, Washtenaw Community College